//
//  ProgramIntroducedPartnersTableViewCell.m
//  RainbowFM
//
//  Created by Kratos on 14/12/9.
//  Copyright (c) 2014年 RB. All rights reserved.
//

#import "ProgramIntroducedPartnersTableViewCell.h"

#import "PartnersIntroducedView.h"

@interface ProgramIntroducedPartnersTableViewCell()<SwipeViewDataSource,SwipeViewDelegate>

@property (nonatomic , strong) NSMutableArray *partnersDate;//商家信息

@end

@implementation ProgramIntroducedPartnersTableViewCell

- (void)awakeFromNib {
    _partnersDate = [NSMutableArray array];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)updatePartnersData:(NSArray *)partnersData
{
    [_partnersDate removeAllObjects];
    [_partnersDate addObjectsFromArray:partnersData];

    [_partnersScrollView reloadData];
}

#pragma mark -SwipeViewDataSource
- (NSInteger)numberOfItemsInSwipeView:(SwipeView *)swipeView
{
    return [_partnersDate count];
}

- (UIView *)swipeView:(SwipeView *)swipeView viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
{
    PartnersIntroducedView *introducedView = (PartnersIntroducedView *)view;
    if (!introducedView) {
        introducedView = _LoadXib(PartnersIntroducedView,nil,nil);
        CGRect frame = introducedView.frame;
        frame.size.width = CGRectGetWidth(self.contentView.bounds);
        frame.size.height = CGRectGetHeight(self.contentView.bounds);
        introducedView.frame = frame;
        
        view = introducedView;
    }
    
    [introducedView.partnerImagesView sd_setImageWithURL:_partnersDate[index] placeholderImage:nil];
    
    return view;
}

#pragma mark - SwipeViewDelegate
- (void)swipeViewCurrentItemIndexDidChange:(SwipeView *)swipeView
{
    if ([_delegate respondsToSelector:@selector(currentItemIndexDidChange:cell:)]) {
        [_delegate currentItemIndexDidChange:swipeView.currentItemIndex cell:self];
    }
}

- (void)swipeView:(SwipeView *)swipeView didSelectItemAtIndex:(NSInteger)index
{
    if ([_delegate respondsToSelector:@selector(didSelectItemAtIndex:cell:)]) {
        [_delegate didSelectItemAtIndex:index cell:self];
    }
}


@end
